<?php

require_once "../common/http.php";
require_once "../common/mysql.php";

$url = "http://api.tushare.pro";
//{"api_name": "stock_basic", "token": "7a37dc57bcb3309fbc47fda4fcf44c7844d3a506debb4323fb6738af"}
$data = array(
    "api_name"=>"stock_basic",
    "token"=>"7a37dc57bcb3309fbc47fda4fcf44c7844d3a506debb4323fb6738af",
);
$res = Http::post($url,$data);
$resData = json_decode($res,true);

$mysql = new MysqlCommon();
foreach($resData["data"]["items"] as $item){
    $sql = "INSERT INTO `tushare`.`stock_basic`(`ts_code`) VALUES ('{$item[0]}')";
    $mysql->insert($sql);
}
echo "完成";
exit(0);

